<template>
  <div class="app">
    <h2 class="app-title">学习组件通信</h2>
    <div class="app-content">
      <div class="app-nav">
        <RouterLink to="/props1" class="nav-link">props</RouterLink>
        <RouterLink to="/custom-event-view" class="nav-link">custom-event</RouterLink>
        <RouterLink to="/mitt-view" class="nav-link">mitt</RouterLink>
        <RouterLink to="/v-model-view" class="nav-link">v-model</RouterLink>
        <RouterLink to="/attrs-view" class="nav-link">$attrs</RouterLink>
        <RouterLink to="/refs-view" class="nav-link">$refs-parent</RouterLink>
        <RouterLink to="/provide-inject-view" class="nav-link">provide-inject</RouterLink>
        <RouterLink to="/pinia-view" class="nav-link">pinia</RouterLink>
        <RouterLink to="/slot-view" class="nav-link">slot</RouterLink>
      </div>
      <div class="app-view">
        <RouterView></RouterView>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup name="App">
</script>

<style scoped>
.app {
  display: flex;
  flex-direction: column;
  width: 100vw;  /* 使用视口宽度单位 */
  height: 100vh; /* 使用视口高度单位 */
  position: absolute; /* 绝对定位 */
  top: 0;
  left: 0;
  margin: 0;
  padding: 0;
}

.app-title {
  width: 100%;
  text-align: center;
  padding: 15px 0;
  background-color: #3a7bd5;
  color: white;
  font-size: 28px;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin: 0;
}

.app-content {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.app-nav {
  width: 200px;
  background: linear-gradient(to bottom, #e6f3ff, #f0f8ff);
  border-right: 1px solid #eaeaea;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.nav-link {
  padding: 15px 20px;
  color: #5a6d8f;
  text-decoration: none;
  transition: all 0.3s ease;
  font-size: 15px;
  position: relative;
}

.nav-link:hover {
  color: #3a7bd5;
  background-color: rgba(208, 230, 255, 0.3);
}

.nav-link.router-link-active {
  color: #3a7bd5;
  background-color: rgba(208, 230, 255, 0.5);
  font-weight: 500;
}

.nav-link.router-link-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background-color: #3a7bd5;
}

.app-view {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: white;
  height: 100%;
}

/* 美化滚动条 */
.app-view::-webkit-scrollbar,
.app-nav::-webkit-scrollbar {
  width: 6px;
}

.app-view::-webkit-scrollbar-track,
.app-nav::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.app-view::-webkit-scrollbar-thumb,
.app-nav::-webkit-scrollbar-thumb {
  background: #c0d6e9;
  border-radius: 3px;
}

.app-view::-webkit-scrollbar-thumb:hover,
.app-nav::-webkit-scrollbar-thumb:hover {
  background: #a0c0e0;
}
</style>
